﻿$(document).ready(function () {
    var lang = $("#CurrentLangCode").html();
    if (lang == "vi-VN") {
        jQuery.validator.addMethod("phone", function (value, element) {
            return this.optional(element) || /0\d{9,10}/.test(value);
        }, "Xin vui lòng chỉ định một số điện thoại hợp lệ.");
        jQuery.validator.addMethod("dob", function (value, element) {
            return this.optional(element) || /^(((((0[1-9])|(1\d)|(2[0-8]))\/((0[1-9])|(1[0-2])))|((31\/((0[13578])|(1[02])))|((29|30)\/((0[1,3-9])|(1[0-2])))))\/((20[0-9][0-9])|(19[0-9][0-9])))|((29\/02\/(19|20)(([02468][048])|([13579][26]))))$/.test(value);
        }, "Ngày sinh không đúng định dạng.");
        $('#contact-form').validate(
     {

         rules: {
             name: {
                 minlength: 10,
                 required: true
             },
             email: {
                 required: true,
                 email: true
             },
             phone: {
                 required: true,
                 phone: true
             },
             term: {
                 required: true,
             },
         },
         messages: {

             name: {

                 minlength: "Họ tên không hợp lệ",
                 required: "Vui lòng nhập họ tên"
             },
             email: {
                 required: "Chúng tôi cần địa chỉ email để liên lạc với bạn",
                 email: "Email chưa đúng định dạng"
             },
             phone: {
                 required: "Chúng tôi cần số điện thoại để liên lạc với bạn",
             },
             term: {
                 required: "Hãy đọc và đồng ý với chính sách của chúng tôi",
             }
         },
         highlight: function (element) {
             $(element).closest('.control-group').removeClass('success').addClass('error');
         },
         success: function (element) {
             element
             .text('OK!').addClass('valid')
             .closest('.control-group').removeClass('error').addClass('success');
         }
     });
    }
    else {
        jQuery.validator.addMethod("phone", function (value, element) {
            return this.optional(element) || /0\d{9,10}/.test(value);
        }, "Please specify a valid phone number.");
        jQuery.validator.addMethod("dob", function (value, element) {
            return this.optional(element) || /^(((((0[1-9])|(1\d)|(2[0-8]))\/((0[1-9])|(1[0-2])))|((31\/((0[13578])|(1[02])))|((29|30)\/((0[1,3-9])|(1[0-2])))))\/((20[0-9][0-9])|(19[0-9][0-9])))|((29\/02\/(19|20)(([02468][048])|([13579][26]))))$/.test(value);
        }, "DOB incorrect format.");
        $('#contact-form').validate(
     {

         rules: {
             name: {
                 minlength: 8,
                 maxlength: 100,
                 required: true
             },
             email: {
                 required: true,
                 email: true
             },
             phone: {
                 maxlength: 11,
                 required: true,
                 phone: true
             },
             term: {
                 required: true
             },
         },
         messages: {

             name: {

                 minlength: "Please input valid name",
                 required: "Please input your name"
             },
             phone: {
                 required: "We need your phone number to contact you",
             },
             email: {
                 required: "We need an email address to contact you",
                 email: "Email incorrect fomat"
             },
             term: {
                 required: "Please read and agree to our policy",
             }
         },
         highlight: function (element) {
             $(element).closest('.control-group').removeClass('success').addClass('error');
         },
         success: function (element) {
             element
             .text('OK!').addClass('valid')
             .closest('.control-group').removeClass('error').addClass('success');
         }
     });
    }
    $('#submit-card').click(function () {
        if ($('#contact-form').valid()) {
            $.mobile.showPageLoadingMsg();
            var lang = $("#CurrentLangCode").html();
            var carid = $("#id-card").html();
            var email = $("#email").val();
            var name = $("#name").val();
            var phone = $("#phone").val();
            var icome = $("#icome").val();
            var dob = $("#dob").val();
            var AppUrl = $("#AppUrl").text();
            $.ajax({
                type: "post",
                url: AppUrl + "/Card/CardApply",
                data: { CardID: carid, CustomerName: name, CustomerEmail: email, CustomerPhone: phone, CustomerIncome: icome, CustomerDOB: dob },
                dataType: "json",
                success: function (rvdata) {
                    if (rvdata == 1) {
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/Account/Register",
                            data: { Email: email, Name: name, Phone: phone, dob: dob },
                            dataType: "json",
                            success: function (result) {
                            }
                        });
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/PartialView/SendEmail",
                            data: { EmailSendTo: email, Name: name },
                            dataType: "json",
                            success: function (result) {
                                $.ajax({
                                    type: "post",
                                    url: AppUrl + "/CreditCard/SendEmail",
                                    data: { Name: name, phone: phone, emailuser: email, CardID: carid },
                                    dataType: "json",
                                    success: function (result) {
                                        $.mobile.hidePageLoadingMsg();
                                        window.location = AppUrl + "/credit-card/thanks-you";
                                    }
                                });
                            }
                        });



                    }
                    else {
                        alert("Error");
                        window.location.reload();
                    }
                }
            });
          
        }
        return false;
    });
    $('#submit-fuelcard').click(function () {
        if ($('#contact-form').valid()) {
            var carid = $("#id-card").html();
            var email = $("#email").val();
            var name = $("#name").val();
            var phone = $("#phone").val();
            var icome = $("#icome").val();
            var dob = $("#dob").val();
            var AppUrl = $("#AppUrl").text();
            $("#loading-apply").fadeIn();
            $.ajax({
                type: "post",
                url: AppUrl + "/Card/CardApply",
                data: { CardID: carid, CustomerName: name, CustomerEmail: email, CustomerPhone: phone, CustomerIncome: icome, CustomerDOB: dob },
                dataType: "json",
                success: function (rvdata) {
                    if (rvdata == 1) {
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/Account/Register",
                            data: { Email: email, Name: name, Phone: phone, dob: dob },
                            dataType: "json",
                            success: function (result) {
                            }
                        });
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/PartialView/SendEmail",
                            data: { EmailSendTo: email, Name: name },
                            dataType: "json",
                            success: function (result) {
                                $.ajax({
                                    type: "post",
                                    url: AppUrl + "/SavingFuelCard/SendEmail",
                                    data: { Name: name, phone: phone, emailuser: email, CardID: carid },
                                    dataType: "json",
                                    success: function (result) {
                                        window.location = AppUrl + "/fuel-card/thanks-you";
                                    }
                                });
                            }
                        });
                       
                    }
                    else {
                        alert("Error");
                        window.location.reload();
                    }
                }
            });
        }
        return false;
    });
    $('#submit-restaurantcard').click(function () {
        if ($('#contact-form').valid()) {
            var carid = $("#id-card").html();
            var email = $("#email").val();
            var name = $("#name").val();
            var phone = $("#phone").val();
            var icome = $("#icome").val();
            var dob = $("#dob").val();
            var AppUrl = $("#AppUrl").text();
            $("#loading-apply").fadeIn();
            $.ajax({
                type: "post",
                url: AppUrl + "/Card/CardApply",
                data: { CardID: carid, CustomerName: name, CustomerEmail: email, CustomerPhone: phone, CustomerIncome: icome, CustomerDOB: dob },
                dataType: "json",
                success: function (rvdata) {
                    if (rvdata == 1) {
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/Account/Register",
                            data: { Email: email, Name: name, Phone: phone, dob: dob },
                            dataType: "json",
                            success: function (result) {
                            }
                        });
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/PartialView/SendEmail",
                            data: { EmailSendTo: email, Name: name },
                            dataType: "json",
                            success: function (result) {
                                $.ajax({
                                    type: "post",
                                    url: AppUrl + "/RestaurantCard/SendEmail",
                                    data: { Name: name, phone: phone, emailuser: email, CardID: carid },
                                    dataType: "json",
                                    success: function (result) {
                                        window.location = AppUrl + "/restaurant-card/thanks-you";
                                    }
                                });
                            }
                        });
                    }
                    else {
                        alert("Error");
                        window.location.reload();
                    }
                }
            });
        }
        return false;
    });
    $('#submit-travelcard').click(function () {
        if ($('#contact-form').valid()) {
            var carid = $("#id-card").html();
            var email = $("#email").val();
            var name = $("#name").val();
            var phone = $("#phone").val();
            var icome = $("#icome").val();
            var dob = $("#dob").val();
            var AppUrl = $("#AppUrl").text();
            $("#loading-apply").fadeIn();
            $.ajax({
                type: "post",
                url: AppUrl + "/Card/CardApply",
                data: { CardID: carid, CustomerName: name, CustomerEmail: email, CustomerPhone: phone, CustomerIncome: icome, CustomerDOB: dob },
                dataType: "json",
                success: function (rvdata) {
                    if (rvdata == 1) {
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/Account/Register",
                            data: { Email: email, Name: name, Phone: phone, dob: dob },
                            dataType: "json",
                            success: function (result) {
                            }
                        });
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/PartialView/SendEmail",
                            data: { EmailSendTo: email, Name: name },
                            dataType: "json",
                            success: function (result) {
                                $.ajax({
                                    type: "post",
                                    url: AppUrl + "/TravelCard/SendEmail",
                                    data: { Name: name, phone: phone, emailuser: email, CardID: carid },
                                    dataType: "json",
                                    success: function (result) {
                                        window.location = AppUrl + "/travel-card/thanks-you";
                                    }
                                });
                            }
                        });
                        
                    }
                    else {
                        alert("Error");
                        window.location.reload();
                    }
                }
            });
        }
        return false;
    });
    $('#submit-shoppingcard').click(function () {
        if ($('#contact-form').valid()) {
            var carid = $("#id-card").html();
            var email = $("#email").val();
            var name = $("#name").val();
            var phone = $("#phone").val();
            var icome = $("#icome").val();
            var dob = $("#dob").val();
            var AppUrl = $("#AppUrl").text();
            $("#loading-apply").fadeIn();
            $.ajax({
                type: "post",
                url: AppUrl + "/Card/CardApply",
                data: { CardID: carid, CustomerName: name, CustomerEmail: email, CustomerPhone: phone, CustomerIncome: icome, CustomerDOB: dob },
                dataType: "json",
                success: function (rvdata) {
                    if (rvdata == 1) {
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/Account/Register",
                            data: { Email: email, Name: name, Phone: phone, dob: dob },
                            dataType: "json",
                            success: function (result) {
                            }
                        });
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/PartialView/SendEmail",
                            data: { EmailSendTo: email, Name: name },
                            dataType: "json",
                            success: function (result) {
                                $.ajax({
                                    type: "post",
                                    url: AppUrl + "/ShoppingCard/SendEmail",
                                    data: { Name: name, phone: phone, emailuser: email, CardID: carid },
                                    dataType: "json",
                                    success: function (result) {
                                        window.location = AppUrl + "/shopping-card/thanks-you";
                                    }
                                });
                            }
                        });
                       
                    }
                    else {
                        alert("Error");
                        window.location.reload();
                    }
                }
            });
        }
        return false;
    });
    $('#submit-atmcard').click(function () {
        if ($('#contact-form').valid()) {
            var carid = $("#id-card").html();
            var email = $("#email").val();
            var name = $("#name").val();
            var phone = $("#phone").val();
            var icome = $("#icome").val();
            var dob = $("#dob").val();
            var AppUrl = $("#AppUrl").text();
            $("#loading-apply").fadeIn();
            $.ajax({
                type: "post",
                url: AppUrl + "/Card/CardApply",
                data: { CardID: carid, CustomerName: name, CustomerEmail: email, CustomerPhone: phone, CustomerIncome: icome, CustomerDOB: dob },
                dataType: "json",
                success: function (rvdata) {
                    if (rvdata == 1) {
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/Account/Register",
                            data: { Email: email, Name: name, Phone: phone, dob: dob },
                            dataType: "json",
                            success: function (result) {
                            }
                        });
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/PartialView/SendEmail",
                            data: { EmailSendTo: email, Name: name },
                            dataType: "json",
                            success: function (result) {
                                $.ajax({
                                    type: "post",
                                    url: AppUrl + "/ATMCard/SendEmail",
                                    data: { Name: name, phone: phone, emailuser: email, CardID: carid },
                                    dataType: "json",
                                    success: function (result) {
                                        window.location = AppUrl + "/atm-card/thanks-you";
                                    }
                                });
                            }
                        });

                      
                    }
                    else {
                        alert("Error");
                        window.location.reload();
                    }
                }
            });
        }
        return false;
    });
    $('#submit-deposit').click(function () {
        if ($('#contact-form').valid()) {
            $.mobile.showPageLoadingMsg();
            var depositid = $("#id-deposit").html();
            var email = $("#email").val();
            var name = $("#name").val();
            var phone = $("#phone").val();
            var icome = $("#icome").val();
            var dob = $("#dob").val();
            var AppUrl = $("#AppUrl").text();
            $("#loading-apply").fadeIn();
            $.ajax({
                type: "post",
                url: AppUrl + "/DepositSaving/DepositSavingApply",
                data: { DepositSavingID: depositid, CustomerName: name, CustomerEmail: email, CustomerPhone: phone, CustomerIncome: icome, CustomerDOB: dob },
                dataType: "json",
                success: function (rvdata) {
                    if (rvdata == 1) {
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/Account/Register",
                            data: { Email: email, Name: name, Phone: phone, dob: dob },
                            dataType: "json",
                            success: function (result) {
                            }
                        });
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/PartialView/SendEmail",
                            data: { EmailSendTo: email, Name: name },
                            dataType: "json",
                            success: function (result) {
                                $.ajax({
                                    type: "post",
                                    url: AppUrl + "/DepositSaving/SendEmail",
                                    data: { Name: name, phone: phone, emailuser: email, CardID: depositid },
                                    dataType: "json",
                                    success: function (result) {
                                        $.mobile.hidePageLoadingMsg();
                                        window.location = AppUrl + "/term-saving/thanks-you";
                                    }
                                });
                            }
                        });
                        
                    }
                    else {
                        alert("Error");
                        window.location.reload();
                    }
                }
            });
        }
        return false;
    });
    $('#submit-accumulate').click(function () {
        if ($('#contact-form').valid()) {
            var accumulateid = $("#id-accumulate").html();
            var email = $("#email").val();
            var name = $("#name").val();
            var phone = $("#phone").val();
            var icome = $("#icome").val();
            var dob = $("#dob").val();
            var AppUrl = $("#AppUrl").text();
            $("#loading-apply").fadeIn();
            $.ajax({
                type: "post",
                url: AppUrl + "/AccumulateDeposit/AccumulateDepositApply",
                data: { AccumulateDepositID: accumulateid, CustomerName: name, CustomerEmail: email, CustomerPhone: phone, CustomerIncome: icome, CustomerDOB: dob },
                dataType: "json",
                success: function (rvdata) {
                    if (rvdata == 1) {
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/Account/Register",
                            data: { Email: email, Name: name, Phone: phone, dob: dob },
                            dataType: "json",
                            success: function (result) {
                            }
                        });
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/PartialView/SendEmail",
                            data: { EmailSendTo: email, Name: name },
                            dataType: "json",
                            success: function (result) {
                                $.ajax({
                                    type: "post",
                                    url: AppUrl + "/AccumulateDeposit/SendEmail",
                                    data: { Name: name, phone: phone, emailuser: email, CardID: accumulateid },
                                    dataType: "json",
                                    success: function (result) {

                                        window.location = AppUrl + "/accumulated-saving/thanks-you";
                                    }
                                });
                            }
                        });

                    }
                    else {
                        alert("Error");
                        window.location.reload();
                    }
                }
            });
        }
        return false;
    });
    $('#submit-online').click(function () {
        if ($('#contact-form').valid()) {
            var accumulateid = $("#id-online").html();
            var email = $("#email").val();
            var name = $("#name").val();
            var phone = $("#phone").val();
            var icome = $("#icome").val();
            var dob = $("#dob").val();
            var AppUrl = $("#AppUrl").text();
            $("#loading-apply").fadeIn();
            $.ajax({
                type: "post",
                url: AppUrl + "/OnlineDeposit/OnlineDepositApply",
                data: { OnlineDepositID: accumulateid, CustomerName: name, CustomerEmail: email, CustomerPhone: phone, CustomerIncome: icome, CustomerDOB: dob },
                dataType: "json",
                success: function (rvdata) {
                    if (rvdata == 1) {
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/Account/Register",
                            data: { Email: email, Name: name, Phone: phone, dob: dob },
                            dataType: "json",
                            success: function (result) {
                            }
                        });
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/PartialView/SendEmail",
                            data: { EmailSendTo: email, Name: name },
                            dataType: "json",
                            success: function (result) {
                                $.ajax({
                                    type: "post",
                                    url: AppUrl + "/OnlineDeposit/SendEmail",
                                    data: { Name: name, phone: phone, emailuser: email, CardID: accumulateid },
                                    dataType: "json",
                                    success: function (result) {
                                        window.location = AppUrl + "/term-demand-saving/thanks-you";
                                    }
                                });
                            }
                        });
                        
                    }
                    else {
                        alert("Error");
                        window.location.reload();
                    }
                }
            });
        }
        return false;
    });
    $('#submit-currency').click(function () {
        if ($('#contact-form').valid()) {
            var currencyid = $("#id-currency").html();
            var email = $("#email").val();
            var name = $("#name").val();
            var phone = $("#phone").val();
            var icome = $("#icome").val();
            var dob = $("#dob").val();
            var AppUrl = $("#AppUrl").text();
            $("#loading-apply").fadeIn();
            $.ajax({
                type: "post",
                url: AppUrl + "/DepositSavingCurrency/SavingCurrencyApply",
                data: { SavingCurrencyID: currencyid, CustomerName: name, CustomerEmail: email, CustomerPhone: phone, CustomerIncome: icome, CustomerDOB: dob },
                dataType: "json",
                success: function (rvdata) {
                    if (rvdata == 1) {
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/Account/Register",
                            data: { Email: email, Name: name, Phone: phone, dob: dob },
                            dataType: "json",
                            success: function (result) {
                            }
                        });
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/PartialView/SendEmail",
                            data: { EmailSendTo: email, Name: name },
                            dataType: "json",
                            success: function (result) {
                                $.ajax({
                                    type: "post",
                                    url: AppUrl + "/DepositSavingCurrency/SendEmail",
                                    data: { Name: name, phone: phone, emailuser: email, CardID: currencyid },
                                    dataType: "json",
                                    success: function (result) {
                                        window.location = AppUrl + "/foreign-currency-saving/thanks-you";
                                    }
                                });
                            }
                        });
                       
                    }
                    else {
                        alert("Error");
                        window.location.reload();
                    }
                }
            });
        }
        return false;
    });
    $('#submit-homeloantrust').click(function () {
        if ($('#contact-form').valid()) {
            var currencyid = $("#id-homeloantrust").html();
            var email = $("#email").val();
            var name = $("#name").val();
            var phone = $("#phone").val();
            var icome = $("#icome").val();
            var dob = $("#dob").val();
            var AppUrl = $("#AppUrl").text();
            $("#loading-apply").fadeIn();
            $.ajax({
                type: "post",
                url: AppUrl + "/HomeLoanTrust/HomeLoanApply",
                data: { HomeLoanID: currencyid, CustomerName: name, CustomerEmail: email, CustomerPhone: phone, CustomerIncome: icome, CustomerDOB: dob },
                dataType: "json",
                success: function (rvdata) {
                    if (rvdata == 1) {
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/Account/Register",
                            data: { Email: email, Name: name, Phone: phone, dob: dob },
                            dataType: "json",
                            success: function (result) {
                            }
                        });
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/PartialView/SendEmail",
                            data: { EmailSendTo: email, Name: name },
                            dataType: "json",
                            success: function (result) {
                                $.ajax({
                                    type: "post",
                                    url: AppUrl + "/HomeLoanTrust/SendEmail",
                                    data: { Name: name, phone: phone, emailuser: email, CardID: currencyid },
                                    dataType: "json",
                                    success: function (result) {
                                        window.location = AppUrl + "/house-contruction-renovation-loan/thanks-you";
                                    }
                                });
                            }
                        });
                       
                    }
                    else {
                        alert("Error");
                        window.location.reload();
                    }
                }
            });
        }
        return false;
    });
    $('#submit-homeloanmortgage').click(function () {
        if ($('#contact-form').valid()) {
            var currencyid = $("#id-homeloanmortgage").html();
            var email = $("#email").val();
            var name = $("#name").val();
            var phone = $("#phone").val();
            var icome = $("#icome").val();
            var dob = $("#dob").val();
            var AppUrl = $("#AppUrl").text();
            $("#loading-apply").fadeIn();
            $.ajax({
                type: "post",
                url: AppUrl + "/HomeLoanTrust/HomeLoanApply",
                data: { HomeLoanID: currencyid, CustomerName: name, CustomerEmail: email, CustomerPhone: phone, CustomerIncome: icome, CustomerDOB: dob },
                dataType: "json",
                success: function (rvdata) {
                    if (rvdata == 1) {
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/Account/Register",
                            data: { Email: email, Name: name, Phone: phone, dob: dob },
                            dataType: "json",
                            success: function (result) {
                            }
                        });
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/PartialView/SendEmail",
                            data: { EmailSendTo: email, Name: name },
                            dataType: "json",
                            success: function (result) {
                                $.ajax({
                                    type: "post",
                                    url: AppUrl + "/HomeLoanMortgage/SendEmail",
                                    data: { Name: name, phone: phone, emailuser: email, CardID: currencyid },
                                    dataType: "json",
                                    success: function (result) {
                                        window.location = AppUrl + "/secured-home-loan/thanks-you";
                                    }
                                });
                            }
                        });
         
                    }
                    else {
                        alert("Error");
                        window.location.reload();
                    }
                }
            });
        }
        return false;
    });
    $('#submit-carloantrust').click(function () {
        if ($('#contact-form').valid()) {
            var currencyid = $("#id-carloantrust").html();
            var email = $("#email").val();
            var name = $("#name").val();
            var phone = $("#phone").val();
            var icome = $("#icome").val();
            var dob = $("#dob").val();
            var AppUrl = $("#AppUrl").text();
            $("#loading-apply").fadeIn();
            $.ajax({
                type: "post",
                url: AppUrl + "/CarLoanTrust/CarLoanApply",
                data: { CarLoanID: currencyid, CustomerName: name, CustomerEmail: email, CustomerPhone: phone, CustomerIncome: icome, CustomerDOB: dob },
                dataType: "json",
                success: function (rvdata) {
                    if (rvdata == 1) {
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/Account/Register",
                            data: { Email: email, Name: name, Phone: phone, dob: dob },
                            dataType: "json",
                            success: function (result) {
                            }
                        });
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/PartialView/SendEmail",
                            data: { EmailSendTo: email, Name: name },
                            dataType: "json",
                            success: function (result) {
                                $.ajax({
                                    type: "post",
                                    url: AppUrl + "/CarLoanTrust/SendEmail",
                                    data: { Name: name, phone: phone, emailuser: email, CardID: currencyid },
                                    dataType: "json",
                                    success: function (result) {
                                        window.location = AppUrl + "/car-loan/thanks-you";
                                    }
                                });
                            }
                        });
                       
                    }
                    else {
                        alert("Error");
                        window.location.reload();
                    }
                }
            });
        }
        return false;
    });
    $('#submit-carloanmortgage').click(function () {
        if ($('#contact-form').valid()) {
            var currencyid = $("#id-carloanmortgage").html();
            var email = $("#email").val();
            var name = $("#name").val();
            var phone = $("#phone").val();
            var icome = $("#icome").val();
            var dob = $("#dob").val();
            var AppUrl = $("#AppUrl").text();
            $("#loading-apply").fadeIn();
            $.ajax({
                type: "post",
                url: AppUrl + "/CarLoanMortgage/CarLoanApply",
                data: { CarLoanID: currencyid, CustomerName: name, CustomerEmail: email, CustomerPhone: phone, CustomerIncome: icome, CustomerDOB: dob },
                dataType: "json",
                success: function (rvdata) {
                    if (rvdata == 1) {
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/Account/Register",
                            data: { Email: email, Name: name, Phone: phone, dob: dob },
                            dataType: "json",
                            success: function (result) {
                            }
                        });
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/PartialView/SendEmail",
                            data: { EmailSendTo: email, Name: name },
                            dataType: "json",
                            success: function (result) {
                                $.ajax({
                                    type: "post",
                                    url: AppUrl + "/CarLoanMortgage/SendEmail",
                                    data: { Name: name, phone: phone, emailuser: email, CardID: currencyid },
                                    dataType: "json",
                                    success: function (result) {
                                        window.location = AppUrl + "/moto-loan/thanks-you";
                                    }
                                });
                            }
                        });
                       
                    }
                    else {
                        alert("Error");
                        window.location.reload();
                    }
                }
            });
        }
        return false;
    });
    $('#submit-shorttermloan').click(function () {
        if ($('#contact-form').valid()) {
            var currencyid = $("#id-shorttermloan").html();
            var email = $("#email").val();
            var name = $("#name").val();
            var phone = $("#phone").val();
            var icome = $("#icome").val();
            var dob = $("#dob").val();
            var AppUrl = $("#AppUrl").text();
            $("#loading-apply").fadeIn();
            $.ajax({
                type: "post",
                url: AppUrl + "/ShortTermLoan/ShortTermLoanApply",
                data: { ShortTermLoanID: currencyid, CustomerName: name, CustomerEmail: email, CustomerPhone: phone, CustomerIncome: icome, CustomerDOB: dob },
                dataType: "json",
                success: function (rvdata) {
                    if (rvdata == 1) {
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/Account/Register",
                            data: { Email: email, Name: name, Phone: phone, dob: dob },
                            dataType: "json",
                            success: function (result) {
                            }
                        });
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/PartialView/SendEmail",
                            data: { EmailSendTo: email, Name: name },
                            dataType: "json",
                            success: function (result) {
                                $.ajax({
                                    type: "post",
                                    url: AppUrl + "/ShortTermLoan/SendEmail",
                                    data: { Name: name, phone: phone, emailuser: email, CardID: currencyid },
                                    dataType: "json",
                                    success: function (result) {
                                        window.location = AppUrl + "/short-term-loan/thanks-you";
                                    }
                                });
                            }
                        });
                       
                    }
                    else {
                        alert("Error");
                        window.location.reload();
                    }
                }
            });
        }
        return false;
    });
    $('#submit-working').click(function () {
        if ($('#contact-form').valid()) {
            var currencyid = $("#id-working").html();
            var email = $("#email").val();
            var name = $("#name").val();
            var phone = $("#phone").val();
            var icome = $("#icome").val();
            var dob = $("#dob").val();
            var AppUrl = $("#AppUrl").text();
            $("#loading-apply").fadeIn();
            $.ajax({
                type: "post",
                url: AppUrl + "/WorkingCapitalLoan/WorkingCapitalLoanApply",
                data: { WorkingCapitalLoanID: currencyid, CustomerName: name, CustomerEmail: email, CustomerPhone: phone, CustomerIncome: icome, CustomerDOB: dob },
                dataType: "json",
                success: function (rvdata) {
                    if (rvdata == 1) {
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/Account/Register",
                            data: { Email: email, Name: name, Phone: phone, dob: dob },
                            dataType: "json",
                            success: function (result) {
                            }
                        });
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/PartialView/SendEmail",
                            data: { EmailSendTo: email, Name: name },
                            dataType: "json",
                            success: function (result) {
                                $.ajax({
                                    type: "post",
                                    url: AppUrl + "/WorkingCapitalLoan/SendEmail",
                                    data: { Name: name, phone: phone, emailuser: email, CardID: currencyid },
                                    dataType: "json",
                                    success: function (result) {
                                        window.location = AppUrl + "/working-capital-loan/thanks-you";
                                    }
                                });
                            }
                        });
                       
                    }
                    else {
                        alert("Error");
                        window.location.reload();
                    }
                }
            });
        }
        return false;
    });
    $('#submit-financial').click(function () {
        if ($('#contact-form').valid()) {
            var currencyid = $("#id-financial").html();
            var email = $("#email").val();
            var name = $("#name").val();
            var phone = $("#phone").val();
            var icome = $("#icome").val();
            var dob = $("#dob").val();
            var AppUrl = $("#AppUrl").text();
            $("#loading-apply").fadeIn();
            $.ajax({
                type: "post",
                url: AppUrl + "/FinancialLeasingLoan/FinancialLeasingLoanApply",
                data: { FinancialLeasingLoanID: currencyid, CustomerName: name, CustomerEmail: email, CustomerPhone: phone, CustomerIncome: icome, CustomerDOB: dob },
                dataType: "json",
                success: function (rvdata) {
                    if (rvdata == 1) {
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/PartialView/SendEmail",
                            data: { EmailSendTo: email, Name: name },
                            dataType: "json",
                            success: function (result) {
                                $.ajax({
                                    type: "post",
                                    url: AppUrl + "/Account/Register",
                                    data: { Email: email, Name: name, Phone: phone, dob: dob },
                                    dataType: "json",
                                    success: function (result) {
                                    }
                                });
                                $.ajax({
                                    type: "post",
                                    url: AppUrl + "/FinancialLeasingLoan/SendEmail",
                                    data: { Name: name, phone: phone, emailuser: email, CardID: currencyid },
                                    dataType: "json",
                                    success: function (result) {
                                        window.location = AppUrl + "/financial-leasing-loan/thanks-you";
                                    }
                                });
                            }
                        });
                       
                    }
                    else {
                        alert("Error");
                        window.location.reload();
                    }
                }
            });
        }
        return false;
    });
    $('#submit-longtermloan').click(function () {
        if ($('#contact-form').valid()) {
            var currencyid = $("#id-longtermloan").html();
            var email = $("#email").val();
            var name = $("#name").val();
            var phone = $("#phone").val();
            var icome = $("#icome").val();
            var dob = $("#dob").val();
            var AppUrl = $("#AppUrl").text();
            $("#loading-apply").fadeIn();
            $.ajax({
                type: "post",
                url: AppUrl + "/LongTermLoan/LongTermLoanApply",
                data: { LongTermLoanID: currencyid, CustomerName: name, CustomerEmail: email, CustomerPhone: phone, CustomerIncome: icome, CustomerDOB: dob },
                dataType: "json",
                success: function (rvdata) {
                    if (rvdata == 1) {
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/PartialView/SendEmail",
                            data: { EmailSendTo: email, Name: name },
                            dataType: "json",
                            success: function (result) {
                                $.ajax({
                                    type: "post",
                                    url: AppUrl + "/Account/Register",
                                    data: { Email: email, Name: name, Phone: phone, dob: dob },
                                    dataType: "json",
                                    success: function (result) {
                                    }
                                });
                                $.ajax({
                                    type: "post",
                                    url: AppUrl + "/LongTermLoan/SendEmail",
                                    data: { Name: name, phone: phone, emailuser: email, CardID: currencyid },
                                    dataType: "json",
                                    success: function (result) {
                                        window.location = AppUrl + "/long-term-loan/thanks-you";
                                    }
                                });
                            }
                        });
                       
                    }
                    else {
                        alert("Error");
                        window.location.reload();
                    }
                }
            });
        }
        return false;
    });
    $('#submit-consumerloan').click(function () {
        if ($('#contact-form').valid()) {
            $.mobile.showPageLoadingMsg();
            var currencyid = $("#id-consumerloan").html();
            var email = $("#email").val();
            var name = $("#name").val();
            var phone = $("#phone").val();
            var icome = $("#icome").val();
            var dob = $("#dob").val();
            var AppUrl = $("#AppUrl").text();
            $("#loading-apply").fadeIn();
            $.ajax({
                type: "post",
                url: AppUrl + "/ConsumerLoan/ConsumerLoanApply",
                data: { ConsumerLoanID: currencyid, CustomerName: name, CustomerEmail: email, CustomerPhone: phone, CustomerIncome: icome, CustomerDOB: dob },
                dataType: "json",
                success: function (rvdata) {
                    if (rvdata == 1) {
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/PartialView/SendEmail",
                            data: { EmailSendTo: email, Name: name },
                            dataType: "json",
                            success: function (result) {
                                $.ajax({
                                    type: "post",
                                    url: AppUrl + "/Account/Register",
                                    data: { Email: email, Name: name, Phone: phone, dob: dob },
                                    dataType: "json",
                                    success: function (result) {
                                    }
                                });
                                $.ajax({
                                    type: "post",
                                    url: AppUrl + "/ConsumerLoan/SendEmail",
                                    data: { Name: name, phone: phone, emailuser: email, CardID: currencyid },
                                    dataType: "json",
                                    success: function (result) {
                                        $.mobile.hidePageLoadingMsg();
                                        window.location = AppUrl + "/consumer-loan/thanks-you";
                                    }
                                });
                            }
                        });
                       
                    }
                    else {
                        alert("Error");
                        window.location.reload();
                    }
                }
            });
        }
        return false;
    });
    $('#submit-educationloan').click(function () {
        if ($('#contact-form').valid()) {
            var currencyid = $("#id-educationloan").html();
            var email = $("#email").val();
            var name = $("#name").val();
            var phone = $("#phone").val();
            var icome = $("#icome").val();
            var dob = $("#dob").val();
            var AppUrl = $("#AppUrl").text();
            $("#loading-apply").fadeIn();
            $.ajax({
                type: "post",
                url: AppUrl + "/EducationLoan/EducationLoanApply",
                data: { EducationLoanID: currencyid, CustomerName: name, CustomerEmail: email, CustomerPhone: phone, CustomerIncome: icome, CustomerDOB: dob },
                dataType: "json",
                success: function (rvdata) {
                    if (rvdata == 1) {
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/PartialView/SendEmail",
                            data: { EmailSendTo: email, Name: name },
                            dataType: "json",
                            success: function (result) {
                                $.ajax({
                                    type: "post",
                                    url: AppUrl + "/Account/Register",
                                    data: { Email: email, Name: name, Phone: phone, dob: dob },
                                    dataType: "json",
                                    success: function (result) {
                                    }
                                });
                                $.ajax({
                                    type: "post",
                                    url: AppUrl + "/EducationLoan/SendEmail",
                                    data: { Name: name, phone: phone, emailuser: email, CardID: currencyid },
                                    dataType: "json",
                                    success: function (result) {
                                        window.location = AppUrl + "/education-loan/thanks-you";
                                    }
                                });
                            }
                        });
                       
                    }
                    else {
                        alert("Error");
                        window.location.reload();
                    }
                }
            });
        }
        return false;
    });
    $('#submit-overdraftloan').click(function () {
        if ($('#contact-form').valid()) {
            var currencyid = $("#id-overdraftloan").html();
            var email = $("#email").val();
            var name = $("#name").val();
            var phone = $("#phone").val();
            var icome = $("#icome").val();
            var dob = $("#dob").val();
            var AppUrl = $("#AppUrl").text();
            $("#loading-apply").fadeIn();
            $.ajax({
                type: "post",
                url: AppUrl + "/OverdraftLoan/OverdraftLoanApply",
                data: { OverdraftLoanID: currencyid, CustomerName: name, CustomerEmail: email, CustomerPhone: phone, CustomerIncome: icome, CustomerDOB: dob },
                dataType: "json",
                success: function (rvdata) {
                    if (rvdata == 1) {
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/PartialView/SendEmail",
                            data: { EmailSendTo: email, Name: name },
                            dataType: "json",
                            success: function (result) {
                                $.ajax({
                                    type: "post",
                                    url: AppUrl + "/Account/Register",
                                    data: { Email: email, Name: name, Phone: phone, dob: dob },
                                    dataType: "json",
                                    success: function (result) {
                                    }
                                });
                                $.ajax({
                                    type: "post",
                                    url: AppUrl + "/OverdraftLoan/SendEmail",
                                    data: { Name: name, phone: phone, emailuser: email, CardID: currencyid },
                                    dataType: "json",
                                    success: function (result) {
                                        window.location = AppUrl + "/overdraft-loan/thanks-you";
                                    }
                                });
                            }
                        });
                        
                    }
                    else {
                        alert("Error");
                        window.location.reload();
                    }
                }
            });
        }
        return false;
    });
    $('#submit-internetbanking').click(function () {
        if ($('#contact-form').valid()) {
            $.mobile.showPageLoadingMsg();
            var currencyid = $("#id-internetbanking").html();
            var email = $("#email").val();
            var name = $("#name").val();
            var phone = $("#phone").val();
            var icome = $("#icome").val();
            var dob = $("#dob").val();
            var CurrentAccount = $(".CurrentAccount").is(":checked");
            var SavingsDeposits = $(".SavingsDeposits").is(":checked");
            var CreditCard = $(".CreditCard").is(":checked");
            var HomeLoan = $(".HomeLoan").is(":checked");
            var CarLoan = $(".CarLoan").is(":checked");
            var PersonalLoan = $(".PersonalLoan").is(":checked");
            var BusinessLoan = $(".BusinessLoan").is(":checked");
            var city = $("#select-city").val();
            $("#loading-apply").fadeIn();
            if ($("#contacttime1").is(":checked")) {
                var contacttime = "Trong giờ làm việc";
            }
            else {
                var contacttime = "Ngoài giờ làm việc";
            }
            var AppUrl = $("#AppUrl").text();
            $.ajax({
                type: "post",
                url: AppUrl + "/InternetBanking/InternetBankingApply",
                data: { InternetBankingID: currencyid, CustomerName: name, CustomerEmail: email, CustomerPhone: phone, CustomerIncome: icome, CustomerDOB: dob, CurrentAccount: CurrentAccount, SavingsDeposits: SavingsDeposits, CreditCard: CreditCard, HomeLoan: HomeLoan, CarLoan: CarLoan, PersonalLoan: PersonalLoan, BusinessLoan: BusinessLoan, City: city, ContactTime: contacttime },
                dataType: "json",
                success: function (rvdata) {
                    if (rvdata == 1) {
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/Account/Register",
                            data: { Email: email, Name: name, Phone: phone, dob: dob },
                            dataType: "json",
                            success: function (result) {
                            }
                        });
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/PartialView/SendEmail",
                            data: { EmailSendTo: email, Name: name },
                            dataType: "json",
                            success: function (result) {
                                $.ajax({
                                    type: "post",
                                    url: AppUrl + "/InternetBanking/SendEmail",
                                    data: { Name: name, phone: phone, emailuser: email, CardID: currencyid },
                                    dataType: "json",
                                    success: function (result) {
                                        $.mobile.hidePageLoadingMsg();
                                        window.location = AppUrl + "/internet-banking/thanks-you";
                                    }
                                });
                            }
                        });
                       
                    }
                    else {
                        alert("Error");
                        window.location.reload();
                    }
                }
            });
        }
        return false;
    });
    $('#submit-mobilebanking').click(function () {
        if ($('#contact-form').valid()) {
            var currencyid = $("#id-mobilebanking").html();
            var email = $("#email").val();
            var name = $("#name").val();
            var phone = $("#phone").val();
            var icome = $("#icome").val();
            var dob = $("#dob").val();
            var CurrentAccount = $("#CurrentAccount").is(":checked");
            var SavingsDeposits = $("#SavingsDeposits").is(":checked");
            var CreditCard = $("#CreditCard").is(":checked");
            var HomeLoan = $("#HomeLoan").is(":checked");
            var CarLoan = $("#CarLoan").is(":checked");
            var PersonalLoan = $("#PersonalLoan").is(":checked");
            var BusinessLoan = $("#BusinessLoan").is(":checked");
            var city = $("#select-city").val();
            $("#loading-apply").fadeIn();
            if ($("#contacttime1").is(":checked")) {
                var contacttime = $("#contacttime1").val();
            }
            else {
                var contacttime = $("#contacttime2").val();
            }
            var AppUrl = $("#AppUrl").text();
            $.ajax({
                type: "post",
                url: AppUrl + "/MobileBanking/MobileBankingApply",
                data: { MobileBankingID: currencyid, CustomerName: name, CustomerEmail: email, CustomerPhone: phone, CustomerIncome: icome, CustomerDOB: dob, CurrentAccount: CurrentAccount, SavingsDeposits: SavingsDeposits, CreditCard: CreditCard, HomeLoan: HomeLoan, CarLoan: CarLoan, PersonalLoan: PersonalLoan, BusinessLoan: BusinessLoan, City: city, ContactTime: contacttime },
                dataType: "json",
                success: function (rvdata) {
                    if (rvdata == 1) {
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/Account/Register",
                            data: { Email: email, Name: name, Phone: phone, dob: dob },
                            dataType: "json",
                            success: function (result) {
                            }
                        });
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/PartialView/SendEmail",
                            data: { EmailSendTo: email, Name: name },
                            dataType: "json",
                            success: function (result) {
                                $.ajax({
                                    type: "post",
                                    url: AppUrl + "/MobileBanking/SendEmail",
                                    data: { Name: name, phone: phone, emailuser: email, CardID: currencyid },
                                    dataType: "json",
                                    success: function (result) {
                                        window.location = AppUrl + "/mobile-banking/thanks-you";
                                    }
                                });
                            }
                        });

                       
                    }
                    else {
                        alert("Error");
                        window.location.reload();
                    }
                }
            });
        }
        return false;
    });
    $('#submit-ConsumerInstallmentLoan').click(function () {
        if ($('#contact-form').valid()) {
            var currencyid = $("#id-ConsumerInstallmentLoan").html();
            var email = $("#email").val();
            var name = $("#name").val();
            var phone = $("#phone").val();
            var icome = $("#icome").val();
            var dob = $("#dob").val();
            var AppUrl = $("#AppUrl").text();
            $("#loading-apply").fadeIn();
            $.ajax({
                type: "post",
                url: AppUrl + "/ConsumerInstallmentLoan/ConsumerInstallmentLoanApply",
                data: { ConsumerInstallmentLoanID: currencyid, CustomerName: name, CustomerEmail: email, CustomerPhone: phone, CustomerIncome: icome, CustomerDOB: dob },
                dataType: "json",
                success: function (rvdata) {
                    if (rvdata == 1) {
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/Account/Register",
                            data: { Email: email, Name: name, Phone: phone, dob: dob },
                            dataType: "json",
                            success: function (result) {
                            }
                        });
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/PartialView/SendEmail",
                            data: { EmailSendTo: email, Name: name },
                            dataType: "json",
                            success: function (result) {
                                $.ajax({
                                    type: "post",
                                    url: AppUrl + "/ConsumerInstallmentLoan/SendEmail",
                                    data: { Name: name, phone: phone, emailuser: email, CardID: currencyid },
                                    dataType: "json",
                                    success: function (result) {
                                        window.location = AppUrl + "/consumer-installment-loan/thanks-you";
                                    }
                                });
                            }
                        });
                       
                    }
                    else {
                        alert("Error");
                        window.location.reload();
                    }
                }
            });
        }
        return false;
    });
    $('#submit-PersonalBusinessLoan').click(function () {
        if ($('#contact-form').valid()) {
            var currencyid = $("#id-PersonalBusinessLoan").html();
            var email = $("#email").val();
            var name = $("#name").val();
            var phone = $("#phone").val();
            var icome = $("#icome").val();
            var dob = $("#dob").val();
            var AppUrl = $("#AppUrl").text();
            $("#loading-apply").fadeIn();
            $.ajax({
                type: "post",
                url: AppUrl + "/PersonalBusinessLoan/PersonalBusinessLoanApply",
                data: { PersonalBusinessLoanID: currencyid, CustomerName: name, CustomerEmail: email, CustomerPhone: phone, CustomerIncome: icome, CustomerDOB: dob },
                dataType: "json",
                success: function (rvdata) {
                    if (rvdata == 1) {
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/Account/Register",
                            data: { Email: email, Name: name, Phone: phone, dob: dob },
                            dataType: "json",
                            success: function (result) {
                            }
                        });
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/PartialView/SendEmail",
                            data: { EmailSendTo: email, Name: name },
                            dataType: "json",
                            success: function (result) {
                                $.ajax({
                                    type: "post",
                                    url: AppUrl + "/PersonalBusinessLoan/SendEmail",
                                    data: { Name: name, phone: phone, emailuser: email, CardID: currencyid },
                                    dataType: "json",
                                    success: function (result) {
                                        window.location = AppUrl + "/personal-business-loan/thanks-you";
                                    }
                                });
                            }
                        });
                       
                    }
                    else {
                        alert("Error");
                        window.location.reload();
                    }
                }
            });
        }
        return false;
    });
    $('#submit-HomeEquityLoan').click(function () {
        if ($('#contact-form').valid()) {
            var currencyid = $("#id-HomeEquityLoan").html();
            var email = $("#email").val();
            var name = $("#name").val();
            var phone = $("#phone").val();
            var icome = $("#icome").val();
            var dob = $("#dob").val();
            var AppUrl = $("#AppUrl").text();
            $("#loading-apply").fadeIn();
            $.ajax({
                type: "post",
                url: AppUrl + "/HomeEquityLoan/HomeEquityLoanApply",
                data: { HomeEquityLoanID: currencyid, CustomerName: name, CustomerEmail: email, CustomerPhone: phone, CustomerIncome: icome, CustomerDOB: dob },
                dataType: "json",
                success: function (rvdata) {
                    if (rvdata == 1) {
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/Account/Register",
                            data: { Email: email, Name: name, Phone: phone, dob: dob },
                            dataType: "json",
                            success: function (result) {
                            }
                        });
                        $.ajax({
                            type: "post",
                            url: AppUrl + "/PartialView/SendEmail",
                            data: { EmailSendTo: email, Name: name },
                            dataType: "json",
                            success: function (result) {
                                $.ajax({
                                    type: "post",
                                    url: AppUrl + "/HomeEquityLoan/SendEmail",
                                    data: { Name: name, phone: phone, emailuser: email, CardID: currencyid },
                                    dataType: "json",
                                    success: function (result) {
                                        window.location = AppUrl + "/home-equity-loan/thanks-you";
                                    }
                                });
                            }
                        });
                       
                    }
                    else {
                        alert("Error");
                        window.location.reload();
                    }
                }
            });
        }
        return false;
    });
});